home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / util / cdity / availmem2.lha / AvailMem2 / src / AvailMem2_settings.s < prev    next >
Text File  |  1997-07-01  |  18KB  |  748 lines

  1.  
  2.     machine 68020
  3.  
  4.  
  5.     * program includes
  6.  
  7.     include    "AvailMem2_gui.i"
  8.     include    "AvailMem2.i"
  9.     include    "lvo.i"
  10.  
  11.     incdir    "include:"
  12.  
  13.     include    "exec/exec.i"
  14.     include    "dos/dos.i"
  15.     include    "dos/dosextens.i"
  16.     include    "libraries/gadtools.i"
  17.  
  18.     * config structure
  19.  
  20.  STRUCTURE ProgramConfig,0
  21.     LONG    cfg_IDString
  22.     LONG    cfg_CfgVersion
  23.     LONG    cfg_ChipDisplayed
  24.     LONG    cfg_FastDisplayed
  25.     LONG    cfg_PublicDisplayed
  26.     LONG    cfg_CPUDisplayed
  27.     LONG    cfg_RenderPercentage
  28.     LONG    cfg_RenderLines
  29.     LONG    cfg_LargMemBlkColour
  30.     LONG    cfg_RemaMemBlkColour
  31.     LONG    cfg_VBLDelay
  32.     LONG    cfg_FlushButtons
  33.     LONG    cfg_MinimizeBorders
  34.     LONG    cfg_RemoveBorder
  35.     LONG    cfg_AlwaysOnTop
  36.     LONG    cfg_GoBackdrop
  37.     WORD    cfg_MDLeftEdge
  38.     WORD    cfg_MDTopEdge
  39.     WORD    cfg_MDWidth
  40.     WORD    cfg_MDHeight
  41.     STRUCT    cfg_WindowTitle,256
  42.     STRUCT    cfg_ScreenName,256
  43.     LABEL    cfg_SIZEOF
  44.  
  45. IDString    equ    "ACFG"        ;config-file string-id
  46. CfgVersion    equ    7        ;config-file version-id
  47.  
  48.     section    code,code        ;availmem code section
  49.  
  50. _HandleSettingsMsgs
  51. * * * * * * * * * * * * * * * * * * * * *
  52. *                    *
  53. * Handles settings window msgs.        *
  54. *                    *
  55. * * * * * * * * * * * * * * * * * * * * *
  56.     movem.l    d0-a6,-(sp)        ;push all registers
  57.  
  58.     clr.l    .prg_SettingsClose    ;reset window close variable
  59.  
  60.     tst.l    SettingsWnd        ;check if settings window open
  61.     beq    .no_SettingsWnd        ;skip if not
  62.  
  63. .MsgLoop_Settings
  64.  
  65.     move.l    _GadToolsBase,a6    ;put gadtoolsbase in a6
  66.     move.l    SettingsWnd,a0        ;get ptr to settings window
  67.     move.l    wd_UserPort(a0),a0    ;get window userport
  68.     jsr    _LVOGT_GetIMsg(a6)    ;get any waiting message
  69.     move.l    d0,ptr_TempMsg        ;store msg
  70.     beq    .no_SettingsWnd        ;if no message, continue looping
  71.  
  72.     move.l    ptr_TempMsg,a4        ;put msg in a4
  73.     move.l    im_Class(a4),d4        ;get msg class
  74.  
  75.     * check setting gadgets
  76.  
  77.     cmp.l    #IDCMP_GADGETUP,d4    ;check if a gadget was pressed
  78.     bne    .no_IDCMP_GADGETUP    ;skip if not
  79.  
  80.     move.l    im_IAddress(a4),a3    ;get ptr to gadget int a3
  81.     move.w    gg_GadgetID(a3),d4    ;get gadget id to d4
  82.  
  83.     cmp.w    #GDX_Ok,d4        ;check if Ok button pressed
  84.     bne    .no_GDX_Ok        ;skip if not
  85.  
  86.     jsr    _ReadSettingsGadgets    ;modify settings
  87.  
  88.     st.l    .prg_SettingsClose    ;set window close variable
  89.  
  90.     clr.l    d4            ;reset msg class
  91.  
  92. .no_GDX_Ok
  93.  
  94.     cmp.w    #GDX_Cancel,d4        ;check if Cancel button pressed
  95.     bne    .no_GDX_Cancel        ;skip if not
  96.  
  97.     st.l    .prg_SettingsClose    ;set window close variable
  98.  
  99.     clr.l    d4            ;reset msg class
  100.  
  101. .no_GDX_Cancel
  102.  
  103.     clr.l    d4            ;reset msg class
  104.  
  105. .no_IDCMP_GADGETUP
  106.  
  107.     cmp.l    #IDCMP_CLOSEWINDOW,d4    ;check if closegadget was pressed
  108.     bne    .not_IDCMP_CLOSEWINDOW    ;skip if not
  109.  
  110.     st.l    .prg_SettingsClose    ;set window close variable
  111.  
  112.     clr.l    d4            ;reset msg class
  113.  
  114. .not_IDCMP_CLOSEWINDOW
  115.  
  116.     move.l    _GadToolsBase,a6    ;put gadtoolsbase in a6
  117.     move.l    ptr_TempMsg,a1        ;put tempmsg in a1
  118.     jsr    _LVOGT_ReplyIMsg(a6)    ;reply window msg
  119.  
  120.     bra    .MsgLoop_Settings    ;loop message-reader
  121.  
  122. .no_SettingsWnd
  123.  
  124.     tst.l    .prg_SettingsClose    ;check if win should close
  125.     beq    .no_SettingsClose    ;skip if it shouldn't
  126.  
  127.     jsr    _CloseGUI        ;close program GUI
  128.  
  129.     jsr    _StoreSettings
  130.     jsr    _RetrieveSettings
  131.  
  132.     jsr    _OpenGUI        ;reopen GUI
  133.     tst.l    d0            ;check if GUI-open succeeded
  134.     beq    .Fail
  135.  
  136. .no_SettingsClose
  137.  
  138.     movem.l    (sp)+,d0-a6        ;pop all registers
  139.     clr.l    d0            ;set exitcode to FALSE
  140.     rts                ;return
  141.  
  142. .Fail
  143.     movem.l    (sp)+,d0-a6        ;pop all registers
  144.     st.l    d0            ;set exitcode to TRUE
  145.     rts                ;return
  146.  
  147. .prg_SettingsClose    ds.l    1
  148. .prg_SettingsChanged    ds.l    1
  149.  
  150. _ReadSettingsGadgets
  151. * * * * * * * * * * * * * * * * * * * * *
  152. *                    *
  153. * Scans the settings-gadgets for    *
  154. * active preferences.            *
  155. *                    *
  156. * * * * * * * * * * * * * * * * * * * * *
  157.  
  158.     movem.l    d0-a6,-(sp)        ;push all registers
  159.  
  160.     * initialize gadget-reading
  161.  
  162.     move.l    _GadToolsBase,a6    ;put gadtoolsbase in a6
  163.     lea.l    SettingsGadgets,a5    ;get ptr to gadgets into a5
  164.     lea.l    _GadgetList,a4        ;get ptr to gadget-list into a4
  165.     lea.l    tag_Output,a3        ;get ptr to multi-taglist into a3
  166.     lea.l    prg_OutputValue,a2    ;get ptr to tag-output into a2
  167.     move.l    a2,4(a3)        ;set standard output variable
  168.  
  169.     * get window title
  170. .ReadSettings
  171.  
  172.     move.l    (a4)+,d0
  173.     tst.l    d0
  174.     beq    .End_Of_Gadgets
  175.  
  176.     subq.l    #1,d0            ;get correct gadget-value
  177.  
  178.     move.l    (a5,d0*4),a0        ;get ptr to gadget into a0
  179.     move.l    SettingsWnd,a1        ;put ptr to settingswnd to a1
  180.     sub.l    a2,a2            ;reset requester
  181.     lea.l    tag_Output,a3        ;get ptr to multi-taglist into a3
  182.     move.l    (a4)+,d4        ;get special gadget-tag into d4
  183.     move.l    d4,(a3)            ;set special gadget-tag
  184.     jsr    _LVOGT_GetGadgetAttrsA(a6);get gadget attributes
  185.  
  186.     move.l    (a4)+,a1        ;get ptr to output variable into a0
  187.  
  188.     cmp.l    #GTST_String,d4
  189.     beq    .string_gadget
  190.  
  191.     move.l    prg_OutputValue,(a1)    ;get output from function
  192.  
  193.     bra    .ReadSettings
  194.  
  195. .string_gadget
  196.  
  197.     move.l    prg_OutputValue,a0    ;get output from function
  198.     jsr    _StringCopy        ;copy gadget string-buffer
  199.  
  200.     bra    .ReadSettings
  201.  
  202. .End_Of_Gadgets
  203.  
  204.     movem.l    (sp)+,d0-a6        ;pop all registers
  205.     rts                ;return
  206.  
  207. _SetSettingsGadgets
  208. * * * * * * * * * * * * * * * * * * * * *
  209. *                    *
  210. * Sets the settings-gadgets with the    *
  211. * active preferences.            *
  212. *                    *
  213. * * * * * * * * * * * * * * * * * * * * *
  214.  
  215.     movem.l    d0-a6,-(sp)        ;push all registers
  216.  
  217.     * initialize gadget-reading
  218.  
  219.     move.l    _GadToolsBase,a6    ;put gadtoolsbase in a6
  220.     lea.l    SettingsGadgets,a5    ;get ptr to gadgets into a5
  221.     lea.l    _GadgetList,a4
  222.  
  223.     * set window title
  224. .SetSettings
  225.  
  226.     move.l    (a4)+,d0
  227.     tst.l    d0
  228.     beq    .End_Of_Gadgets
  229.  
  230.     subq.l    #1,d0
  231.  
  232.     move.l    (a5,d0*4),a0        ;get ptr to string-gadget into a0
  233.     move.l    SettingsWnd,a1        ;put ptr to settingswnd to a1
  234.     lea.l    tag_Output,a3        ;get ptr to multi-taglist into a3
  235.     move.l    (a4)+,(a3)
  236.     move.l    (a4)+,a2
  237.  
  238.     move.l    (a2),d1
  239.  
  240.     cmp.l    #GTST_String,(a3)
  241.     bne    .no_string_gadget
  242.  
  243.     move.l    a2,d1
  244.  
  245. .no_string_gadget
  246.  
  247.     move.l    d1,4(a3)
  248.     sub.l    a2,a2            ;reset requester
  249.  
  250.     jsr    _LVOGT_SetGadgetAttrsA(a6);set gadget attributes
  251.  
  252.     bra    .SetSettings
  253.  
  254. .End_Of_Gadgets
  255.  
  256.     movem.l    (sp)+,d0-a6        ;pop all registers
  257.     rts                ;return
  258.  
  259. _LoadSettings
  260. * * * * * * * * * * * * * * * * * * * * *
  261. *                    *
  262. * Loads new preferences            *
  263. *                    *
  264. * IN:    a0 - ptr to filename.        *
  265. *                    *
  266. * OUT:    d0 - success. (=0 FAIL)        *
  267. *                    *
  268. * * * * * * * * * * * * * * * * * * * * *
  269.  
  270.     movem.l    d0-a6,-(sp)        ; Stack all registers
  271.  
  272.     clr.l    d4            ; Clear filehandle
  273.  
  274.     move.l    _DosBase,a6        ; Dosbase in a6
  275.     move.l    a0,d1            ; Put configfile-name in d1
  276.     move.l    #MODE_OLDFILE,d2    ; Do not create file, just open
  277.     jsr    _LVOOpen(a6)        ; Open config file
  278.     move.l    d0,d4
  279.     tst.l    d0
  280.     beq    .Fail
  281.  
  282.     move.l    d4,d1            ; Put filehandle in d1
  283.     move.l    #prg_MainConfig,d2    ; Put config-file ptr in d2
  284.     move.l    #8,d3            ; Size enough to read header
  285.     jsr    _LVORead(a6)        ; Read header and version
  286.  
  287.     lea.l    prg_MainConfig,a0
  288.     cmp.l    #IDString,(a0)+    ; Check if true 
  289.     bne    .Fail
  290.  
  291.     cmp.l    #CfgVersion,(a0)+    ; Check if version matches
  292.     bne    .Fail
  293.  
  294.     move.l    d4,d1            ; Put filehandle in d1
  295.     move.l    a0,d2            ; Put config-file ptr in d2
  296.     move.l    #cfg_SIZEOF-8,d3    ; Size set to read all
  297.     jsr    _LVORead(a6)        ; Read rest of config-file
  298.     tst.l    d0
  299.     bmi    .Fail
  300.  
  301.     move.l    d4,d1
  302.     jsr    _LVOClose(a6)        ; Close config-file
  303.  
  304.     movem.l    (sp)+,d0-a6        ; Restore all registers
  305.     st.l    d0            ; Return success
  306.     rts                ; Exit procedure
  307.  
  308. .Fail
  309.  
  310.     move.l    d4,d1            ; Put filehandle in d1
  311.     tst.l    d1            ; Check filehandle
  312.     beq    .no_file_open        ; Catch if not open
  313.  
  314.     move.l    d4,d1
  315.     jsr    _LVOClose(a6)        ; Close config-file
  316.  
  317. .no_file_open
  318.  
  319.     movem.l    (sp)+,d0-a6        ; Restore all registers
  320.     clr.l    d0            ; Return failure
  321.     rts                ; Exit procedure
  322.  
  323. _SaveSettings
  324. * * * * * * * * * * * * * * * * * * * * *
  325. *                    *
  326. * Saves the latest stored settings.    *
  327. *                    *
  328. * IN:    a0 - ptr to filename.        *
  329. *                    *
  330. * OUT:    d0 - success. (=0 FAIL)        *
  331. *                    *
  332. * * * * * * * * * * * * * * * * * * * * *
  333.  
  334.     movem.l    d1-a6,-(sp)        ;push all registers
  335.  
  336.     move.l    _DosBase,a6        ; DosBase in a6
  337.     lea.l    prg_MainConfig,a1    ; Config datastruct in a1
  338.     move.l    #IDString,cfg_IDString(a1); Set ID string
  339.     move.l    #CfgVersion,cfg_CfgVersion(a1); Set version number
  340.  
  341.     clr.l    d4            ; Clear filehandle
  342.     clr.l    d7            ; Set failure
  343.  
  344.     move.l    a0,d1            ; Put configfile-name in d1
  345.     move.l    #MODE_NEWFILE,d2    ; create file
  346.     jsr    _LVOOpen(a6)        ; Open config file
  347.     move.l    d0,d4
  348.     beq    .Fail
  349.  
  350.     move.l    d4,d1            ; Put filehandle in d1
  351.     move.l    #prg_MainConfig,d2    ; Put config-file ptr in d2
  352.     move.l    #cfg_SIZEOF,d3        ; Size set to write all
  353.     jsr    _LVOWrite(a6)        ; write config-file
  354.  
  355.     st.l    d7            ; Set success
  356.  
  357. .Fail
  358.  
  359.     move.l    d4,d1            ; Put filehandle in d1
  360.     tst.l    d1            ; Check filehandle
  361.     beq    .no_file_open        ; Catch if not open
  362.  
  363.     jsr    _LVOClose(a6)        ; Close config-file
  364.  
  365. .no_file_open
  366.  
  367.     move.l    d7,d0
  368.  
  369.     movem.l    (sp)+,d1-a6        ;pop all registers
  370.     rts                ;return
  371.  
  372. _LoadMainPreferences
  373. * * * * * * * * * * * * * * * * * * * * *
  374. *                    *
  375. * Shell to scan and load the program    *
  376. * settings.                *
  377. *                    *
  378. * OUT:    d0 - success. (=0 FAIL)        *
  379. *                    *
  380. * * * * * * * * * * * * * * * * * * * * *
  381.  
  382.     movem.l    d0-a6,-(sp)        ;push all registers
  383.  
  384.     lea.l    _ENVName,a0
  385.     jsr    _FindDevice
  386.     tst.l    d0
  387.     beq    .FindENVARC
  388.  
  389.     lea.l    _ENVName,a0
  390.     lea.l    prg_ConfigFileBuffer,a1
  391.     jsr    _StringCopy
  392.     move.l    d0,a1
  393.     subq.l    #1,a1
  394.     move.b    #":",(a1)+
  395.     move.l    ptr_ConfigName,a0
  396.     jsr    _StringCopy
  397.     move.l    d0,a1
  398.     subq.l    #1,a1
  399.     lea.l    prg_ConfigAttach,a0
  400.     jsr    _StringCopy
  401.  
  402.     lea.l    prg_ConfigFileBuffer,a0
  403.     jsr    _LoadSettings
  404.     tst.l    d0
  405.     bne    .PrefLoaded
  406.  
  407. .FindENVARC
  408.  
  409.     lea.l    _ENVARCName,a0
  410.     jsr    _FindDevice
  411.     tst.l    d0
  412.     beq    .PrefNotLoaded
  413.  
  414.     lea.l    _ENVARCName,a0
  415.     lea.l    prg_ConfigFileBuffer,a1
  416.     jsr    _StringCopy
  417.     move.l    d0,a1
  418.     subq.l    #1,a1
  419.     move.b    #":",(a1)+
  420.     move.l    ptr_ConfigName,a0
  421.     jsr    _StringCopy
  422.     move.l    d0,a1
  423.     subq.l    #1,a1
  424.     lea.l    prg_ConfigAttach,a0
  425.     jsr    _StringCopy
  426.  
  427.     lea.l    prg_ConfigFileBuffer,a0
  428.     jsr    _LoadSettings
  429.     tst.l    d0
  430.     beq    .PrefNotLoaded
  431.  
  432. .PrefLoaded
  433.  
  434.     movem.l    (sp)+,d0-a6        ;pop all registers
  435.     st.l    d0            ;set exitcode to TRUE
  436.     rts                ;return
  437.  
  438. .PrefNotLoaded
  439.     jsr    _StoreSettings        ;restore config-area
  440.  
  441.     movem.l    (sp)+,d0-a6        ;pop all registers
  442.     clr.l    d0            ;set exitcode to FALSE
  443.     rts                ;return
  444.  
  445. _SaveMainPreferences
  446. * * * * * * * * * * * * * * * * * * * * *
  447. *                    *
  448. * Shell to scan and save the program    *
  449. * settings.                *
  450. *                    *
  451. * * * * * * * * * * * * * * * * * * * * *
  452.  
  453.     movem.l    d0-a6,-(sp)        ;push all registers
  454.  
  455.     jsr    _StoreSettings
  456.  
  457.     lea.l    _ENVName,a0
  458.     jsr    _FindDevice
  459.     tst.l    d0
  460.     beq    .FindENVARC
  461.  
  462.     lea.l    _ENVName,a0
  463.     lea.l    prg_ConfigFileBuffer,a1
  464.     jsr    _StringCopy
  465.     move.l    d0,a1
  466.     subq.l    #1,a1
  467.     move.b    #":",(a1)+
  468.     move.l    ptr_ConfigName,a0
  469.     jsr    _StringCopy
  470.     move.l    d0,a1
  471.     subq.l    #1,a1
  472.     lea.l    prg_ConfigAttach,a0
  473.     jsr    _StringCopy
  474.  
  475.     lea.l    prg_ConfigFileBuffer,a0
  476.     jsr    _SaveSettings
  477.  
  478. .FindENVARC
  479.  
  480.     lea.l    _ENVARCName,a0
  481.     jsr    _FindDevice
  482.     tst.l    d0
  483.     beq    .SkipSaving
  484.  
  485.     lea.l    _ENVARCName,a0
  486.     lea.l    prg_ConfigFileBuffer,a1
  487.     jsr    _StringCopy
  488.     move.l    d0,a1
  489.     subq.l    #1,a1
  490.     move.b    #":",(a1)+
  491.     move.l    ptr_ConfigName,a0
  492.     jsr    _StringCopy
  493.     move.l    d0,a1
  494.     subq.l    #1,a1
  495.     lea.l    prg_ConfigAttach,a0
  496.     jsr    _StringCopy
  497.  
  498.     lea.l    prg_ConfigFileBuffer,a0
  499.     jsr    _SaveSettings
  500.  
  501. .SkipSaving
  502.  
  503.     movem.l    (sp)+,d0-a6        ;pop all registers
  504.     rts                ;return
  505.  
  506. _RetrieveSettings
  507. * * * * * * * * * * * * * * * * * * * * *
  508. *                    *
  509. * Reads and fills in the program    *
  510. * preferences from the settings-buffer.    *
  511. *                    *
  512. * * * * * * * * * * * * * * * * * * * * *
  513.  
  514.     movem.l    d0-a6,-(sp)        ;push all registers
  515.  
  516.     lea.l    prg_MainConfig,a5    ;get pointer to prg-config into a5
  517.  
  518.     * read settings from cfg-buffer
  519.  
  520.     move.l    cfg_ChipDisplayed(a5),prg_ChipDisplayed
  521.     move.l    cfg_FastDisplayed(a5),prg_FastDisplayed
  522.     move.l    cfg_PublicDisplayed(a5),prg_PublicDisplayed
  523.     move.l    cfg_CPUDisplayed(a5),prg_CPUDisplayed
  524.     move.l    cfg_RenderPercentage(a5),prg_RenderPercentage
  525.     move.l    cfg_RenderLines(a5),prg_RenderLines
  526.     move.l    cfg_LargMemBlkColour(a5),prg_LargMemBlkColour
  527.     move.l    cfg_RemaMemBlkColour(a5),prg_RemaMemBlkColour
  528.     move.l    cfg_GoBackdrop(a5),prg_GoBackdrop
  529.     move.l    cfg_VBLDelay(a5),prg_VBLDelay
  530.     move.l    cfg_FlushButtons(a5),prg_FlushButtons
  531.     move.l    cfg_MinimizeBorders(a5),prg_MinimizeBorders
  532.     move.l    cfg_RemoveBorder(a5),prg_RemoveBorder
  533.     move.l    cfg_AlwaysOnTop(a5),prg_AlwaysOnTop
  534.  
  535.     * copy window settings from buffer
  536.  
  537.     move.w    cfg_MDLeftEdge(a5),MemoryDisplayLeft
  538.     move.w    cfg_MDTopEdge(a5),MemoryDisplayTop
  539.     move.w    cfg_MDWidth(a5),MemoryDisplayWidth
  540.     move.w    cfg_MDHeight(a5),MemoryDisplayHeight
  541.  
  542.     * copy strings from buffer
  543.  
  544.     lea.l    cfg_WindowTitle(a5),a0
  545.     lea.l    prg_WindowTitle,a1
  546.     jsr    _StringCopy
  547.  
  548.     lea.l    cfg_ScreenName(a5),a0
  549.     lea.l    prg_ScreenName,a1
  550.     jsr    _StringCopy
  551.  
  552.     movem.l    (sp)+,d0-a6        ;pop all registers
  553.     rts                ;return
  554.  
  555. _StoreSettings
  556. * * * * * * * * * * * * * * * * * * * * *
  557. *                    *
  558. * Copies the settings to the program    *
  559. * config-structure.            *
  560. *                    *
  561. * * * * * * * * * * * * * * * * * * * * *
  562.  
  563.     movem.l    d0-a6,-(sp)        ;push all registers
  564.  
  565.     lea.l    prg_MainConfig,a5    ;get pointer to prg-config into a5
  566.  
  567.     * write settings to cfg-buffer
  568.  
  569.     move.l    #IDString,cfg_IDString(a5)
  570.     move.l    #CfgVersion,cfg_CfgVersion(a5)
  571.     move.l    prg_ChipDisplayed,cfg_ChipDisplayed(a5)
  572.     move.l    prg_FastDisplayed,cfg_FastDisplayed(a5)
  573.     move.l    prg_PublicDisplayed,cfg_PublicDisplayed(a5)
  574.     move.l    prg_CPUDisplayed,cfg_CPUDisplayed(a5)
  575.     move.l    prg_RenderPercentage,cfg_RenderPercentage(a5)
  576.     move.l    prg_RenderLines,cfg_RenderLines(a5)
  577.     move.l    prg_LargMemBlkColour,cfg_LargMemBlkColour(a5)
  578.     move.l    prg_RemaMemBlkColour,cfg_RemaMemBlkColour(a5)
  579.     move.l    prg_GoBackdrop,cfg_GoBackdrop(a5)
  580.     move.l    prg_VBLDelay,cfg_VBLDelay(a5)
  581.     move.l    prg_FlushButtons,cfg_FlushButtons(a5)
  582.     move.l    prg_MinimizeBorders,cfg_MinimizeBorders(a5)
  583.     move.l    prg_RemoveBorder,cfg_RemoveBorder(a5)
  584.     move.l    prg_AlwaysOnTop,cfg_AlwaysOnTop(a5)
  585.  
  586.     * copy window settings to buffer
  587.  
  588.     move.w    MemoryDisplayLeft,cfg_MDLeftEdge(a5)
  589.     move.w    MemoryDisplayTop,cfg_MDTopEdge(a5)
  590.     move.w    MemoryDisplayWidth,cfg_MDWidth(a5)
  591.     move.w    MemoryDisplayHeight,cfg_MDHeight(a5)
  592.  
  593.     * copy strings to buffer
  594.  
  595.     lea.l    prg_WindowTitle,a0
  596.     lea.l    cfg_WindowTitle(a5),a1
  597.     jsr    _StringCopy
  598.  
  599.     lea.l    prg_ScreenName,a0
  600.     lea.l    cfg_ScreenName(a5),a1
  601.     jsr    _StringCopy
  602.  
  603.     movem.l    (sp)+,d0-a6        ;pop all registers
  604.     rts                ;return
  605.  
  606. _FindDevice
  607. * * * * * * * * * * * * * * * * * * * * *
  608. * Checks if a device really exists,    *
  609. * without getting complaining        *
  610. * requesters.                *
  611. *                    *
  612. * IN:    a0 - ptr to device name.    *
  613. *                    *
  614. * OUT:    d0 - Success. (=0 FAIL)        *
  615. *                    *
  616. * * * * * * * * * * * * * * * * * * * * *
  617.  
  618.     movem.l    d1-a6,-(sp)        ;stack all registers
  619.  
  620.     move.l    a0,a2            ;store device name in a2
  621.  
  622.     move.l    _DosBase,a6        ;dosBase in a6
  623.     move.l    #(LDF_ALL!LDF_READ),d1    ;device flags
  624.     jsr    _LVOLockDosList(a6)    ;lock Doslist
  625.     move.l    d0,.prg_DosList        ;store DosList ptr
  626.  
  627.     move.l    .prg_DosList,d1        ;put DosList in d1
  628.     move.l    a2,d2            ;put device name in d2
  629.     move.l    #(LDF_ALL),d3        ;device flags
  630.     jsr    _LVOFindDosEntry(a6)    ;find device matching name
  631.     move.l    d0,d7            ;store new Doslist-ptr
  632.  
  633.     move.l    #(LDF_ALL!LDF_READ),d1    ;device flags
  634.     jsr    _LVOUnLockDosList(a6)    ;unlock Doslist
  635.  
  636.     move.l    d7,d0            ;put result in d0
  637.     movem.l    (sp)+,d1-a6        ;restore all registers
  638.     rts                ;exit procedure
  639.  
  640. .prg_DosList        ds.l    1
  641.  
  642. _ResetToDefaults
  643.     movem.l    d0-a6,-(sp)
  644.  
  645.     lea.l    prg_MainConfig,a4
  646.  
  647.     st.l    cfg_ChipDisplayed(a4)
  648.     st.l    cfg_FastDisplayed(a4)
  649.     clr.l    cfg_PublicDisplayed(a4)
  650.     clr.l    cfg_CPUDisplayed(a4)
  651.     clr.l    cfg_RenderLines(a4)
  652.     clr.l    cfg_RenderPercentage(a4)
  653.     clr.l    cfg_FlushButtons(a4)
  654.     clr.l    cfg_MinimizeBorders(a4)
  655.     clr.l    cfg_RemoveBorder(a4)
  656.     clr.l    cfg_AlwaysOnTop(a4)
  657.     clr.l    cfg_GoBackdrop(a4)
  658.     move.l    #3,cfg_LargMemBlkColour(a4)
  659.     move.l    #2,cfg_RemaMemBlkColour(a4)
  660.     move.l    #3-1,cfg_VBLDelay(a4)    ;initalize delay variable
  661.  
  662.     lea.l    _DefWindowTitle,a0    ;get ptr to def. window-title into a0
  663.     lea.l    cfg_WindowTitle(a4),a1    ;get ptr to mem-display window title
  664.     jsr    _StringCopy
  665.  
  666.     move.b    #0,cfg_ScreenName(a4)    ;reset screen-name
  667.  
  668.     move.w    #439,cfg_MDLeftEdge(a4)
  669.     move.w    #11,cfg_MDTopEdge(a4)
  670.     move.w    #201,cfg_MDWidth(a4)
  671.     move.w    #27,cfg_MDHeight(a4)
  672.  
  673.     movem.l    (sp)+,d0-a6
  674.     rts
  675.  
  676.     section    data,data        ;availmem data section
  677.  
  678. _GadgetList
  679.     dc.l    1+GDX_WindowTitle,GTST_String,prg_WindowTitle
  680.     dc.l    1+GDX_ScreenName,GTST_String,prg_ScreenName
  681.  
  682.     dc.l    1+GDX_ChipMemory,GTCB_Checked,prg_ChipDisplayed
  683.     dc.l    1+GDX_FastMemory,GTCB_Checked,prg_FastDisplayed
  684.     dc.l    1+GDX_PublicMemory,GTCB_Checked,prg_PublicDisplayed
  685.     dc.l    1+GDX_CPUUsage,GTCB_Checked,prg_CPUDisplayed
  686.  
  687.     dc.l    1+GDX_Seperative_Lines,GTCB_Checked,prg_RenderLines
  688.     dc.l    1+GDX_Percentage,GTCB_Checked,prg_RenderPercentage
  689.     dc.l    1+GDX_FlushButtons,GTCB_Checked,prg_FlushButtons
  690.     dc.l    1+GDX_GoBackdrop,GTCB_Checked,prg_GoBackdrop
  691.  
  692.     dc.l    1+GDX_MinimizedBorders,GTCB_Checked,prg_MinimizeBorders
  693.     dc.l    1+GDX_RemoveBorders,GTCB_Checked,prg_RemoveBorder
  694.  
  695.     dc.l    1+GDX_AlwaysOnTop,GTCB_Checked,prg_AlwaysOnTop
  696.  
  697.     dc.l    1+GDX_LargestMemBlock,GTPA_Color,prg_LargMemBlkColour
  698.     dc.l    1+GDX_RemainingMemBlock,GTPA_Color,prg_RemaMemBlkColour
  699.  
  700.     dc.l    1+GDX_RefreshRate,GTCY_Active,prg_VBLDelay
  701.  
  702.     dc.l    0            ;end of list
  703.  
  704. * config names
  705.  
  706. _ENVName        dc.b    "ENV",0
  707. _ENVARCName        dc.b    "ENVARC",0
  708.  
  709. * default window title
  710.  
  711. _DefWindowTitle        dc.b    "Available Memory",0
  712.  
  713.     section    bss,bss            ;availmem bss section
  714.  
  715. prg_ChipDisplayed    ds.l    1    ;program chipbar variable
  716. prg_FastDisplayed    ds.l    1    ;program fastbar variable
  717. prg_PublicDisplayed    ds.l    1    ;program publicbar variable
  718. prg_CPUUsage        ds.l    1    ;program CPU usage variable
  719. prg_CPUDisplayed    ds.l    1    ;program CPU display variable
  720. prg_RenderPercentage    ds.l    1    ;program render percentage bool
  721. prg_RenderLines        ds.l    1    ;program renderlines bool
  722. prg_LargMemBlkColour    ds.l    1    ;colour of largest memoryblock
  723. prg_RemaMemBlkColour    ds.l    1    ;colour of remaining memoryblock
  724. prg_VBLDelay        ds.l    1    ;Program VBL delay between checks
  725. prg_FlushButtons    ds.l    1    ;program flushbuttons bool
  726. prg_MinimizeBorders    ds.l    1    ;program smallwindow bool
  727. prg_RemoveBorder    ds.l    1    ;program remborders bool
  728. prg_AlwaysOnTop        ds.l    1    ;program on top bool
  729. prg_GoBackdrop        ds.l    1    ;program backdrop bool
  730. prg_WindowTitle        ds.b    256    ;mem-display window title
  731. prg_ScreenName        ds.b    256    ;program popup screen-name
  732.  
  733. * preference name pointers
  734.  
  735. ptr_ProgramConfig    ds.l    1    ;ptr to ENV config-name
  736. ptr_StaticConfig    ds.l    1    ;ptr to ENVARC config-name
  737.  
  738. * multipurpose Gadtools taglist
  739.  
  740. prg_OutputValue        ds.l    1
  741. tag_Output
  742.     dc.l    0,0
  743.     dc.l    TAG_END            ;Ok, BSS, but TAG_END=0 anyway.. :)
  744.  
  745. prg_MainConfig        ds.b    cfg_SIZEOF;program config area
  746.  
  747. prg_ConfigFileBuffer    ds.b    256
  748.